import json

from util import httpTool

BASE_PATH = "iot/api/v1/v1/device/sensor/data/"


def list(req):
    path = BASE_PATH + "list"
    resStr = httpTool.doPost(path, json.dumps(req))
    if resStr:
        res = json.loads(resStr)
        return res['data']
    else:
        return []


def listWithExplain(req):
    path = BASE_PATH + "listWithExplain"
    resStr = httpTool.doPost(path, json.dumps(req))
    if resStr:
        res = json.loads(resStr)
        return res['data']
    else:
        return []
